<template>
  <div class="app-container" style="margin-left: 50px; margin-top: 20px">
    <el-form :inline="true" class="demo-form-inline">
      <!-- 活动区域@change="handleChange"该方法被我删掉了，我觉得没什么用 -->
      <el-form-item label="医院地址">
        <el-cascader v-model="formInline.region" :options="options"></el-cascader>
      </el-form-item>
      <el-form-item label="医院名称">
        <el-input v-model="formInline.name" placeholder="医院名称"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="list" style="width: 100%" border fit highlight-current-row>
      <el-table-column label="序号" width="70" align="center">
        <template slot-scope="scope">
          {{ (page - 1) * limit + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column prop="logo" label="医院logo" width="180">
      </el-table-column>
      <el-table-column prop="hosname" label="医院名称"> </el-table-column>
      <el-table-column prop="hostype" label="医院等级"> </el-table-column>
      <el-table-column prop="address" label="医院地址"> </el-table-column>
      <el-table-column prop="status" label="状态"> </el-table-column>
      <el-table-column prop="creation" label="创建时间"> </el-table-column>
      <el-table-column label="操作" width="200" align="center">
      </el-table-column>

      <!-- <el-table-column label="操作" width="200" align="center">
        <template slot-scope="scope">
          <router-link :to="scope.row.status == 0 ? false : '/hospset/edit/' + scope.row.id">
            <el-button
              type="primary"
              size="mini"
              icon="el-icon-edit"
              :disabled="scope.row.status == 0 ? true : false"
              >修改</el-button
            >
          </router-link>


          <el-button
            type="danger"
            size="mini"
            icon="el-icon-delete"
            @click="lockHospitalSet(scope.row.id)"
            >{{ scope.row.status === 1 ? "锁定" : "解锁" }}</el-button
          >


          <el-button
            type="danger"
            size="mini"
            icon="el-icon-delete"
            :disabled="scope.row.status == 0 ? true : false"
            @click="removeDataById(scope.row.id)"
            >删除</el-button
          > -->
    </el-table>
    <el-pagination
      layout="prev, pager, next, jumper"
      :total="total"
      :page-size="limit"
      :page-count="total"
      :pager-count="pagercount"
      :current-page="page"
      style="padding: 30px 0; text-align: center"
      @current-change="getHospitalList"
    >
    </el-pagination>
  </div>
</template>


<script>
import hospital from "@/api/yygh/hosp";
export default {
  data() {
    return {
    HospitalQueryVo:{},
          // 最多显示页码数
      pagercount: 5,
      // 数据列表
      list: null,
      // 第几页
      page: 1,
      // 每页数据量
      limit: 10,
      total: 0,
      formInline:{
        name: '',
        region: []
      },
      options: [],
      tableData: [{}],
    };
  },
 
  created() {
     this.getHospitalList();
  },
  methods: {
    onSubmit() {
      console.log("submit!");
    },
    getHospitalList(page = 1) {
      //设置一个默认值
      this.page = page;

      //    获取当前页数据
      hospital.getHospOrdinaryPage(page, this.limit).then(response=>{
          
           //每页数据集合
            this.list = response.data.page.content
            //总记录数
            this.total = response.data.page.totalElements
            console.log(response.data.page.content);
           console.log(response.data.page.totalElements);
      }).catch(()=>{
          console.log("出错了");
      });
    },
  },
};
</script>